<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE HTML>
<html>
<head>
    <%@ include file="../../static/_head.jsp" %>
    <title>新增公告</title>
</head>
<body>
<article class="page-container">
    <form class="form form-horizontal" id="form-add">
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3">公告类型：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <span class="select-box">
                    <select class="select" size="1" name="type">
                        <option value="1">顶部公告</option>
                        <option value="2">通知公告</option>
                    </select>
				</span>
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>公告标题：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" id="title" name="title">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>公告内容：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <textarea id="context" name="context" style="width: 80%;height: 150px"></textarea>
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3">公告状态：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <span class="select-box">
                    <select class="select" size="1" name="state">
                        <option value="0">禁用</option>
                        <option value="1">启用</option>
                    </select>
				</span>
            </div>
        </div>
        <div class="row cl">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                <button class="btn btn-primary radius" type="submit">提交</button>
            </div>
        </div>
    </form>
</article>
<%@ include file="../../static/_footer.jsp" %>
<script>
    $("#form-add").validate({
        rules: {
            type: {
                required: true,
            },
            title: {
                required: true,
            },
            context: {
                required: true
            }
        },
        onkeyup: false,
        focusCleanup: true,
        success: "valid",
        submitHandler: function (form) {
            $(form).ajaxSubmit({
                type: 'post',
                url: '/information/notice/add',
                data:$(form).serialize(),
                success: function (data) {
                    if (data.code==200){
                        var index = parent.layer.getFrameIndex(window.name);
                        layer.msg("数据保存中...",{time: 2000},function () {
                            parent.location.reload();
                            parent.layer.close(index);
                        });
                    }else{
                        layer.msg("数据保存失败...");
                    }
                }
            });
        }
    });
</script>
</body>
</html>
